package com.lcredu.spring.component;

import com.lcredu.spring.annotation.Autowired;
import com.lcredu.spring.annotation.Component;
import com.lcredu.spring.annotation.Scope;
import com.lcredu.spring.processe.InitializingBean;

/**
 * @author 黎长容
 * @date 2025-07-16 15:07
 * 1. 使用@Component("monsterService") 修饰
 * 2. 给该 MonsterService 注入到容器设置 beanName 为 monsterService
 * 3. 如果没有设置，默认可以以类名 首字母小写来玩(底层还有很多细节
 */
@Scope(value = "prototype")
@Component(value = "monsterService") //注入到容器
public class MonsterService implements InitializingBean {
    @Autowired
    private MonsterDao monsterDao;
    
    public void sayHi(){
        monsterDao.hi();
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        //bean的初始化方法
        System.out.println("bean的初始化方法 -- MonsterService -- afterPropertiesSet -- 被调用");
    }
}
